package com.ocom.aiot.controller;

import com.ocom.aiot.service.SaasInfoService;
import com.ocom.common.constant.AiotUrl;
import com.ocom.common.entity.aiot.EntitySaasInfo;
import com.ocom.common.enums.ResultEnum;
import com.ocom.common.resp.Result;
import com.ocom.common.utils.ResultUtil;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.GetMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
public class SaasInfoController {
    private final Logger log = LoggerFactory.getLogger(SaasInfoController.class);
    @Autowired
    private SaasInfoService saasInfoService;

    // 2.2.1.获取消费设备Saas平台列表(getSaasNameList)
    @GetMapping(AiotUrl.Url_Aiot_GetSaasNameList)
    public Result GetSaasNameList(String saasNo, String saasName){
        List<EntitySaasInfo> entitySaasInfos = null;
        try {
            entitySaasInfos = saasInfoService.GetSaasNameList(saasNo, saasName);

        }catch (Exception exception){
            log.error("执行获取消费设备Saas平台列表失败",exception.getMessage());
            return ResultUtil.error(ResultEnum.Err_2009,entitySaasInfos);
        }
        if (entitySaasInfos == null){
            log.error("获取消费设备Saas平台列表失败",entitySaasInfos);
            return ResultUtil.error(ResultEnum.Err_1001,entitySaasInfos);
        }
        return ResultUtil.success(entitySaasInfos);
    }
}
